package net.dgg.zz.credential.qualification.service;

import net.dgg.framework.tac.utils.idutil.DggKeyWorker;
import net.dgg.iboss.base.service.CmsService;
import net.dgg.iboss.base.util.DateUtil;
import net.dgg.tmd.foundation.platform.common.util.TranslateUtil;
import net.dgg.tmd.foundation.platform.org.service.OrganizationManager;
import net.dgg.tmd.foundation.platform.session.SessionManager;
import net.dgg.tmd.foundation.platform.user.entity.UserEntity;
import net.dgg.zz.common.constant.CredentialConstant;
import net.dgg.zz.common.service.CommonService;
import net.dgg.zz.common.systemRecord.entity.SystemRecord;
import net.dgg.zz.common.systemRecord.service.SystemRecordService;
import net.dgg.zz.common.utils.DateUtils;
import net.dgg.zz.common.utils.StringUtils;
import net.dgg.zz.common.utils.ValidateUtils;
import net.dgg.zz.credential.baseCredential.entity.BaseCredential;
import net.dgg.zz.credential.baseCredential.service.BaseCredentialService;
import net.dgg.zz.credential.certificateSpecialty.entity.CertificateSpecialty;
import net.dgg.zz.credential.certificateSpecialty.service.CertificateSpecialtyService;
import net.dgg.zz.credential.certificateType.entity.CertificateType;
import net.dgg.zz.credential.certificateType.service.CertificateTypeService;
import net.dgg.zz.credential.excption.CertificateExcption;
import net.dgg.zz.credential.generalCredential.service.GeneralCredentialService;
import net.dgg.zz.credential.qualification.dao.QualificationDao;
import net.dgg.zz.credential.qualification.entity.Qualification;
import net.dgg.zz.credential.storageCapacity.entity.StorageCapacity;
import net.dgg.zz.credential.storageCapacity.service.StorageCapacityService;
import net.dgg.zz.credential.warningConfigure.constant.WarningType;
import net.dgg.zz.credential.warningConfigure.service.SystemConfigureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;

@Service
public class QualificationService {

    @Autowired
    private QualificationDao qualificationDao;
    @Autowired
    private BaseCredentialService baseCredentialService;

    @Autowired
    private CertificateTypeService certificateTypeService;

    @Autowired
    private CertificateSpecialtyService specialtyService;

    @Autowired
    private StorageCapacityService storageCapacityService;

    @Autowired
    private SessionManager sessionManager;

    @Autowired
    private OrganizationManager organizationManager;

    //c操作日志
    @Autowired
    private SystemRecordService systemRecordService;


    @Autowired
    private CmsService cmsService;

    @Autowired
    private CommonService commonService;

    @Autowired
    private GeneralCredentialService generalCredentialService;

    @Autowired
    private TranslateUtil translateUtil;

    @Autowired
    private SystemConfigureService configureService;

    public int insertQualification(Qualification qualification, BaseCredential baseCredential) {
        UserEntity user = sessionManager.getCurrentUser();
        Long orgid = organizationManager.findOrgParentIdByIdAndOrgLevel(user.getOrgId(), "ORG_LEVEL_1");
        if (orgid == null) {
            orgid = user.getOrgId();
        }
        Map orgMap = cmsService.findOrg(orgid);
        String orgName = (String) orgMap.get("name");
        Date date = new Date();
        baseCredential.setCreaterId(user.getId());
        baseCredential.setCreaterName(user.getRealName() + "//" + user.getLoginName());
        baseCredential.setCreaterOrgId(user.getOrgId());
        baseCredential.setCreaterOrgName(orgName);
        baseCredential.setCreateTime(date);
        baseCredential.setCertificateStatus(CredentialConstant.CERTIFICATE_APTITUDE_STATUS_ONE);
        baseCredential.setOverdueStatus(CredentialConstant.CERTIFICATE_APTITUDE_EXCEED_ONE);
        baseCredential.setGeneralType(CredentialConstant.ZZ_CREDENTIAL);
        baseCredential.setSignOrgId(orgid);
        baseCredential.setSignOrgName(orgName);
        int i = qualificationDao.insert(qualification);
        int j = baseCredentialService.insert(baseCredential);
        return i + j;
    }

    public int updateQualification(Qualification qualification, BaseCredential baseCredential) {
        UserEntity user = sessionManager.getCurrentUser();
        Long orgid = organizationManager.findOrgParentIdByIdAndOrgLevel(user.getOrgId(), "ORG_LEVEL_1");
        if (orgid == null) {
            orgid = user.getOrgId();
        }
        Map orgMap = cmsService.findOrg(orgid);
        String orgName = (String) orgMap.get("name");
        Date date = new Date();
        baseCredential.setUpdaterId(user.getId());
        baseCredential.setUpdaterName(user.getRealName() + "//" + user.getLoginName());
        baseCredential.setUpdaterOrgId(user.getOrgId());
        baseCredential.setUpdaterOrgName(orgName);
        baseCredential.setUpdateTime(date);
        int i = qualificationDao.updateByPrimaryKeySelective(qualification);
        int j = baseCredentialService.updateByPrimaryKeySelective(baseCredential);
        return i + j;
    }

    public Qualification selectByPrimaryKey(Long id) {
        return qualificationDao.selectByPrimaryKey(id);
    }

    /**
     * 根据id查询资质全部信息
     *
     * @param id
     * @return
     */
    public Map findById(Long id) {
        Map map = qualificationDao.findById(id);
        //查询附件类
        /*map.put( "annexList","");*/
        return map;
    }

    /**
     * 根据条件差尊
     *
     * @param params
     * @return
     */
    public List<Map> queryDataWithPage(Map params) {
        params.put("generalType", CredentialConstant.ZZ_CREDENTIAL);
        params.put("statusFive", CredentialConstant.CERTIFICATE_APTITUDE_STATUS_FIVE);
        return qualificationDao.queryDataWithPage(params);
    }

    /**
     * 资质总览的数量查询
     *
     * @param params
     * @return
     */
    public Long countPandectTotal(Map params) {
        params.put("generalType", CredentialConstant.ZZ_CREDENTIAL);
        return qualificationDao.countPandectTotal(params);
    }


    /**
     * <p>@Description 资质列表数据</p>
     * <p>@author mqy</p>
     * <p>@Time 2018/8/29 0029 15:38 创建时间</p>
     * <p>@return</p>
     */
    public List<Qualification> findMatchData(Map params) {
        return qualificationDao.findMatchDataWithPage(params);
    }

    /**
     * <p>@Description 生产订单详情搜索搜索的</p>
     * <p>@author mqy</p>
     * <p>@Time 2018/8/31 0031 11:36 创建时间</p>
     * <p>@return</p>
     */
    public List<Map> findQualificationDetailData(Map params) {
        return qualificationDao.findQualificationDetailData(params);
    }


    /**
     * <p>@Description 根据条件查统计: 初步用于根据生产订单ID查绑定了多少个资质</p>
     * <p>@author mqy</p>
     * <p>@Time 2018/8/29 0028 11:30 创建时间</p>
     * <p>@return</p>
     */
    public int queryQualificationProductNumber(Map params) {
        return qualificationDao.queryQualificationProductNumber(params);
    }

    /**
     * 查询字典的资质类型、超期状态、适用范围、资质等级
     *
     * @param model
     * @param params types:数组1:资质类型、2.超期状态、3.资质状态、4.适用范围、5.资质等级
     */
    public void findZiDian(Model model, Map params) {
        model.addAttribute("generalType", CredentialConstant.ZZ_CREDENTIAL);
        //资质等级
        List<Map> certificateLevels = commonService.queryTreeBook(CredentialConstant.QUALIFICATION_LEVEL, 1, 2, null);
        model.addAttribute("certificateLevels", certificateLevels);
        int[] types = (int[]) params.get("types");
        for (int type : types) {
            if (type == 1) {
                params.put("parentId", 0);
                List<Map> typeList = certificateTypeService.getCertificateType(params);
                model.addAttribute("typeList", typeList);
            } else if (type == 2) {
                //超期状态
                List<Map> overdueStatuss = commonService.queryTreeBook(CredentialConstant.CERTIFICATE_APTITUDE_EXCEED, 1, 2, null);
                model.addAttribute("overdueStatuss", overdueStatuss);
            } else if (type == 3) {
                //资质状态
                List<Map> certificateStatus = commonService.queryTreeBook(CredentialConstant.CERTIFICATE_APTITUDE_STATUS, 1, 2, null);
                //移除待审核状态
                for (Iterator it = certificateStatus.iterator(); it.hasNext(); ) {
                    Map str = (Map) it.next();
                    if (str.get("code").equals(CredentialConstant.CERTIFICATE_APTITUDE_STATUS_FIVE)) {
                        it.remove();
                    }
                }
                model.addAttribute("certificateStatus", certificateStatus);
            } else if (type == 4) {
                //适用范围
                List<Map> applicationScopes = commonService.queryTreeBook(CredentialConstant.CREDENTIAL_APPLICATION_SCOPE, 1, 2, null);
                model.addAttribute("applicationScopes", applicationScopes);
            }
        }

    }

    /**
     * 增加操作日志
     *
     * @param baseCredential 证书（资质）基本类
     * @param qualification  资质类
     * @param operateType    操作类型
     * @param remarks        备注
     * @param workTableName  操作的表名
     */
    public void saveSystemRecord(BaseCredential baseCredential, Qualification qualification, String operateType, String remarks, String workTableName) {
        SystemRecord record = new SystemRecord();
        record.setSource("4");
        record.setWorkTableName(workTableName);
        record.setOperateType(operateType);
        record.setRemarks(remarks);
        record.setWorkId(qualification.getQualificationId());
        record.setWorkNo(baseCredential.getCertificateNo());
        record.setCertificateName(baseCredential.getCertificateName());
        record.setCertificateType(baseCredential.getCertificateType());
        record.setCertificateCode(baseCredential.getCertificateNo());
        systemRecordService.save(record);
    }

    /**
     * 增加类型基础表
     *
     * @return
     */
    public List<StorageCapacity> insertStorageCapacity(UserEntity user, Map params, List<Long> certificateMajorIds, String type) {
        StorageCapacity storageCapacity = null;
        List<StorageCapacity> storageCapacityList = new ArrayList<>();
        for (Long certificateMajorId : certificateMajorIds) {
            params.put("certificateMajorId", certificateMajorId);
            List<StorageCapacity> mapList = storageCapacityService.findByCondition(params);
            Date date = new Date();
            if (mapList.size() != 0) {//已存在
                storageCapacity = mapList.get(0);
                storageCapacityList.add(mapList.get(0));
                if (type.equals("1")) {
                    storageCapacity.setLibraryNumbers((mapList.get(0).getLibraryNumbers()) - 1);
                } else if (type.equals("2")) {
                    storageCapacity.setLibraryNumbers((mapList.get(0).getLibraryNumbers()) + 1);
                } else if (type.equals("3")) {
                    storageCapacity.setReserveNumbers((mapList.get(0).getReserveNumbers()) + 1);
                    storageCapacity.setOrderNumbers((mapList.get(0).getOrderNumbers()) - 1);
                }
                storageCapacityService.update(storageCapacity);
            } else {
                storageCapacity = new StorageCapacity();
                //查询证书(资质)类型Id
                Map typeMap = new HashMap();
                typeMap.put("generalType", params.get("generalType"));
                CertificateType certificateType = certificateTypeService.findById(certificateMajorId);
                storageCapacity.setGeneralType(CredentialConstant.ZZ_CREDENTIAL);
                storageCapacity.setCertificateTypeId(certificateType.getParentId());
                storageCapacity.setCertificateLevel((String) params.get("certificateLevel"));
                storageCapacity.setCertificateArea((String) params.get("certificateArea"));
                storageCapacity.setApplicationScope((String) params.get("applicationScope"));
                storageCapacity.setCertificateCode((String) params.get("certificateCode"));
                storageCapacity.setSignOrgId((Long) params.get("signOrgId"));
                storageCapacity.setSignOrgName((String) params.get("signOrgName"));
                storageCapacity.setCreaterId(user.getId());
                storageCapacity.setCreaterName(user.getRealName() + "//" + user.getLoginName());
                storageCapacity.setCreaterOrgId(user.getOrgId());
                storageCapacity.setCreateTime(date);
                storageCapacity.setCreateUser(user);
                storageCapacity.setUpdaterId(user.getId());
                storageCapacity.setUpdaterName(user.getRealName() + "//" + user.getLoginName());
                storageCapacity.setUpdaterOrgId(user.getOrgId());
                storageCapacity.setUpdateTime(date);
                storageCapacity.setUpdaterUser(user);
                storageCapacity.setLibraryNumbers(1);
                storageCapacity.setReserveNumbers(0);
                storageCapacity.setOrderNumbers(0);
                storageCapacity.setSignOrgId((Long) params.get("signOrgId"));
                storageCapacity.setSignOrgName((String) params.get("signOrgName"));
                storageCapacity.setId(DggKeyWorker.nextId());
                storageCapacity.setCertificateMajorId(certificateMajorId);
                storageCapacityService.insert(storageCapacity);
                storageCapacityList.add(storageCapacity);
            }
        }
        return storageCapacityList;
    }

    //增加证书(资质)类型表
    public List<Long> addCertificateSpecialty(BaseCredential baseCredential, String certificateMajorIdStr) {
        try {
            CertificateSpecialty certificateSpecialty = new CertificateSpecialty();
            certificateSpecialty.setType(CredentialConstant.ZZ_CREDENTIAL);
            certificateSpecialty.setCertificateCode(baseCredential.getCertificateNo());
            certificateSpecialty.setCertificateId(baseCredential.getId());
            List<Long> certificateMajorIds = new ArrayList<>();
            for (String id : certificateMajorIdStr.split(",")) {
                CertificateType certificateType = certificateTypeService.findById(Long.parseLong(id));
                certificateSpecialty.setCertificateSpecialtyId(certificateType.getId());
                certificateSpecialty.setCertificateTypeId(certificateType.getParentId());
                certificateSpecialty.setId(DggKeyWorker.nextId());
                specialtyService.insert(certificateSpecialty);
                certificateMajorIds.add(certificateType.getId());
            }
            return certificateMajorIds;
        } catch (Exception e) {
            return null;
        }

    }

    /**
     * 保存或修改资质信息
     */
    @Transactional
    public void saveUpdate(Map params) throws ParseException {
        ValidateUtils.strNotEmpty(params.get("saveType"), CertificateExcption.class, "保存类型为空");
        ValidateUtils.strNotEmpty(params.get("qualificationId"), CertificateExcption.class, "资质id为空");
        ValidateUtils.strNotEmpty(params.get("certificateType"), CertificateExcption.class, "资质类型为空");
        ValidateUtils.strNotEmpty(params.get("certificateName"), CertificateExcption.class, "资质名称为空");
        ValidateUtils.strNotEmpty(params.get("certificateLevel"), CertificateExcption.class, "资质等级为空");
        ValidateUtils.strNotEmpty(params.get("applicationScope"), CertificateExcption.class, "适用范围为空");
        ValidateUtils.strNotEmpty(params.get("companyName"), CertificateExcption.class, "资质所属企业为空");
        ValidateUtils.strNotEmpty(params.get("certificateNo"), CertificateExcption.class, "资质编号为空");
        ValidateUtils.strNotEmpty(params.get("receiptPrice"), CertificateExcption.class, "成本价格为空");
        ValidateUtils.strNotEmpty(params.get("certificateExpiryTime"), CertificateExcption.class, "资质过期时间为空");
        ValidateUtils.strNotEmpty(params.get("certificateArea"), CertificateExcption.class, "地区为空");

        baseCredentialService.checkAptitudeNo(params);// 验证编号重复

        String certificateType = params.get("certificateType").toString();
        String certificateName = params.get("certificateName").toString();
        String certificateLevel = params.get("certificateLevel").toString();
        String applicationScope = params.get("applicationScope").toString();
        String companyName = params.get("companyName").toString();
        String certificateNo = params.get("certificateNo").toString();
        String receiptPrice = params.get("receiptPrice").toString();
        Date ertificateExpiryTime = DateUtils.getDate(params.get("certificateExpiryTime").toString(), "yyyy-MM-dd");
        String certificateArea = params.get("certificateArea").toString();

        UserEntity userEntity = sessionManager.getCurrentUser();
        Map user = cmsService.findUser(userEntity.getId());
        Map depart = cmsService.findOrgParent(userEntity.getOrgId(), "ORG_LEVEL_1");
        BaseCredential baseCredential = new BaseCredential();

        // 组装参数
        params.put("certificateSpecialty", params.get("certificateName"));
        params.put("certificateTypeId", params.get("certificateType"));
        params.put("generalType", CredentialConstant.ZZ_CREDENTIAL);
        ValidateUtils.isTrue(StringUtils.isNotEmpty(depart.get("id")), CertificateExcption.class, "您所在的部门为事业部以上级别，不能进行新增");
        params.put("signOrgId", depart.get("id"));

        if ("add".equals(params.get("saveType"))) {// 新增
            // 资质基本信息
            baseCredential.setId(Long.parseLong(params.get("qualificationId").toString()));
            baseCredential.setGeneralType(CredentialConstant.ZZ_CREDENTIAL);
            baseCredential.setCertificateName(certificateName);
            baseCredential.setCertificateType(certificateType);
            baseCredential.setCertificateLevel(certificateLevel);
            baseCredential.setApplicationScope(applicationScope);
            baseCredential.setCertificateNo(certificateNo);
            baseCredential.setCertificateArea(certificateArea);
            baseCredential.setCertificateExpiryTime(ertificateExpiryTime);
            baseCredential.setReceiptPrice(new BigDecimal(receiptPrice));
            if (StringUtils.isNotEmpty(user.get("id"))) {
                baseCredential.setCollectorId(Long.parseLong(user.get("id").toString()));
                baseCredential.setCollectorName(user.get("realName").toString());
                baseCredential.setCollectorOrgId(Long.parseLong(user.get("orgId").toString()));
                baseCredential.setCollectorOrgName(user.get("orgName").toString());
            }
            if (StringUtils.isNotEmpty(depart.get("id"))) {
                baseCredential.setSignOrgId(Long.parseLong(depart.get("id").toString()));
                baseCredential.setSignOrgId(Long.parseLong(depart.get("id").toString()));
                baseCredential.setSignOrgName(depart.get("name").toString());
            }
            baseCredential.setCertificateStatus(CredentialConstant.CERTIFICATE_APTITUDE_STATUS_ONE);
            baseCredential.setOverdueStatus(CredentialConstant.CERTIFICATE_APTITUDE_EXCEED_ONE);

            Map<String, String> map = baseCredentialService.dealArea(params.get("areaName").toString(), baseCredential.getCertificateArea());
            if (StringUtils.isNotEmpty(map)) { // 如果用户选择的是省/市
                baseCredential.setAreaProvince(map.get("pcode").toString());
            } else { // 如果只选择了省
                baseCredential.setAreaProvince(baseCredential.getCertificateArea());
                baseCredential.setCertificateArea(null);
            }

            baseCredential.setCreateUser(userEntity);
            baseCredential.setUpdaterUser(userEntity);

            // 资质信息
            Qualification qualification = new Qualification();
            qualification.setQualificationId(Long.parseLong(params.get("qualificationId").toString()));
            qualification.setBaseId(baseCredential.getId());
            qualification.setCompanyName(companyName);

            baseCredentialService.insert(baseCredential);
            qualificationDao.insert(qualification);

            this.saveSystemRecord(baseCredential, qualification, "1", "新增资质", "zz_qualification");

            List<StorageCapacity> storageCapacityList = generalCredentialService.verificationStorageCapacityAndBoundV3(baseCredential.getId(), params,null);
            generalCredentialService.boundProductReservation(baseCredential.getId(), storageCapacityList, false);//查询预约绑定
        } else if ("modify".equals(params.get("saveType"))) {// 修改
            Long qualificationId = Long.parseLong(params.get("qualificationId").toString());
            Qualification qualification = qualificationDao.selectByPrimaryKey(qualificationId);
            baseCredential = baseCredentialService.selectByPrimaryKey(qualification.getBaseId());

            Boolean certificateExpiryTimeOverDue = StringUtils.isNotEmpty(ertificateExpiryTime) && DateUtil.daysBetween(ertificateExpiryTime, new Date()) > 0 ? false : true;
            if (certificateExpiryTimeOverDue) {
                baseCredential.setOverdueStatus(CredentialConstant.CERTIFICATE_APTITUDE_EXCEED_ONE);
            } else {
                baseCredential.setOverdueStatus(CredentialConstant.CERTIFICATE_APTITUDE_EXCEED_TWO);
            }

            baseCredential.setCertificateName(certificateName);
            baseCredential.setCertificateType(certificateType);
            baseCredential.setCertificateLevel(certificateLevel);
            baseCredential.setApplicationScope(applicationScope);
            baseCredential.setCertificateNo(certificateNo);
            baseCredential.setCertificateExpiryTime(ertificateExpiryTime);
            baseCredential.setReceiptPrice(new BigDecimal(receiptPrice));
            baseCredential.setCertificateArea(certificateArea);
            Map<String, String> map = baseCredentialService.dealArea(params.get("areaName").toString(), baseCredential.getCertificateArea());
            if (StringUtils.isNotEmpty(map)) { // 如果用户选择的是省/市
                baseCredential.setAreaProvince(map.get("pcode").toString());
            } else { // 如果只选择了省
                baseCredential.setAreaProvince(baseCredential.getCertificateArea());
                baseCredential.setCertificateArea(null);
            }
            baseCredential.setUpdaterUser(userEntity);

            qualification.setCompanyName(companyName);

            baseCredentialService.updateByPrimaryKeySelective(baseCredential);
            qualificationDao.updateByPrimaryKey(qualification);

            this.saveSystemRecord(baseCredential, qualification, "2", "修改资质", "zz_qualification");

            List<StorageCapacity> storageCapacityList = generalCredentialService.verificationStorageCapacityAndBoundV3(baseCredential.getId(), params, baseCredential);
            if (CredentialConstant.CERTIFICATE_APTITUDE_STATUS_ONE.equals(baseCredential.getCertificateStatus()) && baseCredential.getOverdueStatus().equals(CredentialConstant.CERTIFICATE_APTITUDE_EXCEED_ONE)) {
                generalCredentialService.boundProductReservation(baseCredential.getId(), storageCapacityList, false);//查询预约绑定
            }
        }
    }

    /*
     * @Author zsx
     * @Date 2018-09-05 08:09:34
     * @Description 分页获取资质过期预警
     * @param params
     * @return List<Map<String, Object>>
     */
    public List<Map<String, Object>> findExpirationWarningWithPage(Map<String, Object> params) {
        if (params.containsKey("isAll") && params.get("isAll").equals("0")) {
            params.put("signOrgId", commonService.findUserSyb(sessionManager.getCurrentUser()));
        }
        params.put("generalType", CredentialConstant.ZZ_CREDENTIAL);
        params.put("aptitudeStatus", CredentialConstant.CERTIFICATE_APTITUDE_STATUS_FIVE);
        if (StringUtils.isNotEmpty(params.get("signOrgId"))) {
            if (null == params.get("orderColumn")) {
                params.put("orderDir", "ASC");
                params.put("orderColumn", "bc.certificate_expiry_time");
            }
            //查询预警值
            Map<String, Object> map = new HashMap<>();
            map.put("signOrgId", params.get("signOrgId"));
            map.put("warningType", CredentialConstant.ZZ_CREDENTIAL);
            map.put("warningName", WarningType.CERTIFICATE_EXPIRE_WARNING);
            Map<String, Object> warningMap = configureService.querySingleWarning(map);
            Integer warningValue = warningMap.get("configValue") == null ? 0 : Integer.parseInt(warningMap.get("configValue").toString());
            params.put("warningTime", DateUtils.getFewDaysAgo(warningValue));
            List<Map<String, Object>> list = qualificationDao.selectSignOrgExpirationWarningWithPage(params);
            String[] column = {"certificateLevel"};
            return translateUtil.translateList(column, list);
        } else if (null == params.get("orderColumn")) {
            params.put("orderDir", "ASC");
            params.put("orderColumn", "AG.certificateExpiryTime");
        }
        List<Map<String, Object>> list = qualificationDao.selectAllExpirationWarningWithPage(params);
        String[] column = {"certificateLevel"};
        return translateUtil.translateList(column, list);
    }

    /*
     * @Author zsx
     * @Date 2018-09-13 06:09:24
     * @Description 统计资质数据
     * @param param
     * @return Map
     */
    public Map findAptitudecount(Map params) {
        if (params.containsKey("isAll") && params.get("isAll").equals("0")) {
            params.put("signOrgId", commonService.findUserSyb(sessionManager.getCurrentUser()));
        }
        params.put("generalType", CredentialConstant.ZZ_CREDENTIAL);
        //资质预定
        params.put("reservation", CredentialConstant.CERTIFICATE_APTITUDE_STATUS_TWO);
        //全国
        params.put("local", CredentialConstant.LOCAL);
        //本地
        params.put("nationwide", CredentialConstant.NATIONWIDE);
        params.put("status", CredentialConstant.CERTIFICATE_APTITUDE_STATUS_FIVE);
        return qualificationDao.findAptitudecount(params);
    }

}
